package com.app.TCES.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.app.TCES.domain.Class;
import com.app.TCES.domain.Class_Course;
import com.app.TCES.domain.Course;
import com.app.TCES.domain.Department;
import com.app.TCES.domain.Teacher_Course;
import com.app.TCES.mapper.A_Class_CourseMapper;

@Service
public class A_Class_CourseService {

	@Autowired
	A_Class_CourseMapper a_Class_CourseMapper;
	
	//查询所有班级课程
	public List<Class_Course> selectClass_Courses(){
		List<Class_Course> list = a_Class_CourseMapper.selectClass_Courses();
		
		return list;
	}
	
	//查询院系信息
	public List<Department> selectDept(){
		List<Department> list = a_Class_CourseMapper.selectDept();
		return list;
	}
	
	//查询班级信息
	public List<Class> selectClasses(int deptId){
		List<Class> list =a_Class_CourseMapper.selectClasses(deptId);
		return list;
	}
	
	//查询课程信息
	public List<Course> selectCourses(){
		List<Course> list = a_Class_CourseMapper.selectCourses();
		return list;
	}
	
	//添加班级课程
	public String  insertClass_Course(int classId,int courseId,int tchId) {
		
		int a = a_Class_CourseMapper.selectTol(classId, courseId);
		if (a>0) {
			return "NO";
		}else {
			a_Class_CourseMapper.insertCC(classId, courseId,tchId);
			
			return "YES";
		}

	}
	
	//删除信息
	public String delete(int classId,int courseId,int tchId) {
		
		
		a_Class_CourseMapper.deleteCC(a_Class_CourseMapper.selectCCid(classId, courseId,tchId));
		
		
		
		return "YES";
	
	}
	
	//通过课程查找相应的教师
	public List<Teacher_Course> selectC_T(int courseId,int deptId){
		List<Teacher_Course> list = a_Class_CourseMapper.selectC_T(courseId,deptId);
		return list;
	}
	
	//查询班级信息(条件:deptName)
	public List<Class> selectClass(String deptName){
		List<Class> list = a_Class_CourseMapper.selectClass(deptName);
		return list;
	}
	
	//点击院系按钮查找信息(条件:deptName)
	public List<Class_Course> selectMsgBy_deptName(String deptName){
		List<Class_Course> list = a_Class_CourseMapper.selectMsgBy_deptName(deptName);
		return list;
	}
	
	//点击班级按钮查找信息(条件:className)
	public List<Class_Course> selectMsgBy_className(String className,String deptName){
		List<Class_Course> list = a_Class_CourseMapper.selectMsgBy_className(className,deptName);
		return list;
	}
}
